<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.Calendar" %>
<% String title = "信息综合系统"; %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>
<title><%=title %>-季度任务管理</title>
<!-- 页面加载前显示loading -->
<script src="${pageContext.request.contextPath}/js/loading.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-itunes-app" content="app-id=429849944"/>
<meta name="apple-touch-fullscreen" content="no"/>
<meta content="telephone=no" name="format-detection"/>
<meta name="apple-mobile-web-app-capable" content="no"/>
</head>

<!-- BEGIN BODY -->
<body class="fixed-top" style="background: #fff;">
<div class="container-fluid">
    <!-- BEGIN PAGE HEADER-->
    <div class="row-fluid">
        <div class="span12">
            <ul class="breadcrumb" style="padding-bottom : 12px;background: #fff;">
                 <li>
                   <a href="${pageContext.request.contextPath}/user/index.do">
                   		<i class="icon-angle-left"></i>
						<i class="icon-angle-left"></i> &nbsp;&nbsp;
                   		首页控制台</a>
                       <span class="divider">/</span></li>
                       
                <li class="active">季度任务管理</li>
                <li class="pull-right search-wrap">
                    <button
						 onclick="toggleCondi();" 
						 class="btn dropdown-toggle" data-toggle="dropdown">
						<span id="but_text">隐藏筛选区域</span> 
						<i id="toggleCondi_i" class="icon-angle-up"></i>
						</button>
                     &nbsp;&nbsp;
                     <div class="btn-group pull-right">
                        <button class="btn dropdown-toggle" data-toggle="dropdown">更多 <i class="icon-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="${pageContext.request.contextPath}/task/download.do">下载已筛选中标库记录</a></li>
                        </ul>
                    </div>     
                </li>
            </ul>
        </div>
    </div>
    
    <div class="widget">
            <div class="row-fluid">
                <div class="clearfix" >
                <form id="filterForm">
                <input type="text" class="span2" id="province" name="province" placeholder="请填写省份" />
                <input type="text" class="span2 typeahead" id="client" name="client" placeholder="请填写客户" data-provide="typeahead" data-items="4" />

                <input type="button" id="seach" name="seach" value="查询" class="btn  btn-primary"
                           style="margin-bottom: 10px;"
                           onclick="query(pNumber,pSize);">
                <input type="reset" id="reset" name="reset" value="重置该页面" class="btn  btn-primary"
                    style="margin-bottom: 10px;" onclick="resetf();"/>
                </form>
                </div>
            </div>
           
           <div class="row-fluid">
             <div class="span12">
                 <!-- BEGIN EXAMPLE TABLE widget-->
                 <div class="widget purple">
                     <div class="widget-title">
                         <h4><i class="icon-reorder"></i> Editable Table</h4>
                        <span class="tools">
                            <a href="javascript:;" class="icon-chevron-down"></a>
                            <a href="javascript:;" class="icon-remove"></a>
                        </span>
                     </div>
                     <div class="widget-body">
                         <div>
                             <div class="clearfix">
                                 <div class="btn-group">
                                     <button id="editable-sample_new" class="btn green">
                                         Add New <i class="icon-plus"></i>
                                     </button>
                                 </div>
                                 <div class="btn-group pull-right">
                                     <button class="btn dropdown-toggle" data-toggle="dropdown">Tools <i class="icon-angle-down"></i>
                                     </button>
                                     <ul class="dropdown-menu pull-right">
                                         <li><a href="#">Print</a></li>
                                         <li><a href="#">Save as PDF</a></li>
                                         <li><a href="#">Export to Excel</a></li>
                                     </ul>
                                 </div>
                             </div>
                             <div class="space15"></div>
                             <div id="editable-sample_wrapper" class="dataTables_wrapper form-inline" role="grid">
                             <div class="row-fluid">
                             <table class="table table-striped table-hover table-bordered dataTable" id="editable-sample" aria-describedby="editable-sample_info">
                                 <thead>
                                 <tr role="row">
                                    <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="Username" style="width: 50px;">ID</th>
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">省份</th>             
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">地市</th>             
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 140px;">区县</th>             
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 100px;">片区经理</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">客户</th>             
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 100px;">客户级别 </th>          
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 80px;">产品</th>            
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 80px;">包装</th>            
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 150px;">终端QS名</th>          
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">终端类型</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 100px;">终端级别</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 140px;">是否为重点终端</th>        
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">是否为重点区县</th>        
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">协议测算价</th>          
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 140px;">上季度第一月纯销</th>       
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">上季度第二月纯销</th>       
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">上季度第三月纯销</th>       
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 140px;">当前季度第一月纯销目标</th>    
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">当前季度第二月纯销目标</th>    
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">当前季度第三月纯销目标</th>    
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 140px;">目标增长率</th>          
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">活动安排</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">活动费用</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 140px;">批复判断</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 140px;">当前季度实际纯销</th>       
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Notes: activate to sort column ascending" style="width: 140px;">目标完成率</th>          
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Full Name: activate to sort column ascending" style="width: 40px;">实际支出</th>           
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Points: activate to sort column ascending" style="width: 300px;">备注</th>             
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Edit: activate to sort column ascending" style="width: 40px;">Edit</th>
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="editable-sample" rowspan="1" colspan="1" aria-label="Delete: activate to sort column ascending" style="width: 40px;">Delete</th>
                                 </tr>
                                 </thead>
                                 <tbody role="alert" aria-live="polite" aria-relevant="all" id="distribute-body"></tbody>
                             </table>
                           </div>
                         </div>
                     </div>
                 </div>
                 <!-- END EXAMPLE TABLE widget-->
             </div>
         </div>
        </div>
    </div>
</div>

<!-- 页面模板基本js -->
<script src="${pageContext.request.contextPath}/js/jquery-1.7.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.nicescroll.js" type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/js/fullcalendar.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.easy-pie-chart.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.sparkline.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/Chart.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.scrollTo.min.js"></script>
<script src="${pageContext.request.contextPath}/js/common-scripts.js"></script>

<!-- layer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer/layer.js"></script>
<!-- 下拉多选，过滤-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-multiselect.css" type="text/css"/>
<!-- 自动补全 -->
<script src="${pageContext.request.contextPath}/js/bootstrap-typeahead.js"></script>
<!-- 分页-->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/extendPagination.js"></script>
<!-- 日期 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<!-- 复制 -->
<script src="${pageContext.request.contextPath}/js/jquery.zclip.min.js" type="text/javascript" ></script>

<link rel="stylesheet" href="${pageContext.request.contextPath}/css/uniform.default.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/DT_bootstrap.css">
<script src="${pageContext.request.contextPath}/js/editable-table.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.nicescroll.js" ></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.blockui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.uniform.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/DT_bootstrap.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.scrollTo.min.js"></script>

<!-- 自定义的script方法 -->
<script type="text/javascript">
    $(document).ready(function () {
        $("#show").click(function () {
            $(".clearfix").slideToggle();
        });
    });
    if ( window.clipboardData ) {
        $('#getProp').click(function() {
            var ids = getProp();  
            if(selectedIds.trim().length>0){
               ids = selectedIds;
            }
            if(ids.trim().length>0){
                window.clipboardData.setData("Text", ids);
                layer.msg("复制成功！"); 
                $("#allAndNotAll").attr("checked", false);  
                $("input[name='choice']:checkbox").each(function(){ 
                    $(this).attr("checked", false);  
                });
                layer.msg("复制成功！");
            }else{
                layer.alert("您没有选中行！");
            }
        });
    } else {
        $("#getProp").zclip({
            path:'http://img3.job1001.com/js/ZeroClipboard/ZeroClipboard.swf',
            copy:function(){
                   var ids = getProp();  
                   if(selectedIds.trim().length>0){
                       ids = selectedIds;
                    }
                   if(ids.trim().length>0){
                       return ids;
                   }else{
                       layer.msg("您没有选中行！");
                   }
                },
            afterCopy:function(){
                layer.msg("复制成功！"); 
                $("#allAndNotAll").attr("checked", false);  
                $("input[name='choice']:checkbox").each(function(){ 
                    $(this).attr("checked", false);  
                });
                layer.msg("复制成功！");
            }
        });
    }
</script>

<script type="text/javascript">
    function query(pageNumber, pageSize) {
        var url = "${pageContext.request.contextPath }/task/selectForList.do";
        var params = $("#filterForm").serialize();
        sendRequest(url, params, function(ret) {
	        var result = ret.msg;//Msg对象里的msg属性
	        var code = ret.code;//Msg对象里的code属性
	        if(code > 0){//请求正常
	        	createTable(result);
	        }else {//请求异常
	            layer.alert(msg);
	        }
        });
    }

    //动态创建table
    function createTable(items) {
        var html = [];
        for (var i = 0; i < items.length; i++) {
        	if(i%2==0){
        		html.push("<tr class='odd'>");
        	}else{
        		html.push("<tr class='even'>");
        	}
        	html.push('<td class="  sorting_1">' + formatData(items[i].id) + '</td>');
        	html.push('<td class=" ">' + formatData(items[i].province) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].city) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].country) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].mgr) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].client) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].clientLevel) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].product ) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].page) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].terminalQs) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].terminalType) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].terminalLevel) + '</td>'); 
            html.push('<td class=" ">' + formatData(items[i].isTerminal) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].isCountry) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].policyPrice) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].m1) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].m2) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].m3) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].taskM1) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].taskM2) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].taskM3) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].taskGrowthRate) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].event) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].eventPrice) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].eventRef) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].quarterActual) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].completeRate) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].actualCost) + '</td>');
            html.push('<td class=" ">' + formatData(items[i].note) + '</td>');
            html.push('<td class=" "><a class="edit" href="javascript:;">Edit</a></td>');
            html.push('<td class=" "><a class="delete" href="javascript:;">Delete</a></td>');
            html.push('</tr>');
        }
        var mainObj = $('#distribute-body');
        mainObj.empty();
        mainObj.html(html.join(''));
        console.log(html);
        EditableTable.init();
    };


</script>
<!-- END BODY -->
<script>
    var htmls = $("#updateTaskForm").html();
    var ret = null;
    //所有选中的id
    var selectedIds = "";
    //全选或全不选
    $("#allAndNotAll").click(function() { 
        if (this.checked){  
            $("input[name='choice']:checkbox").each(function(){ 
                  $(this).attr("checked", true);  
            });
            layer.msg('拼命执行中，请稍等……', {icon: 16}, function(){
                layer.closeAll();
                layer.load(2);
                //发送异步请求，获取数据
                sendRequest(pageContextPath + "/task/selectIds.do", null, function (jsonData) {
                    selectedIds = jsonData.ids;
                    layer.closeAll();
                });
            });
        } else {   
            $("input[name='choice']:checkbox").each(function() {   
                  $(this).attr("checked", false);  
            });
            selectedIds="";
        }  
    });
</script>
<script src="${pageContext.request.contextPath}/javascript/httpService.js"></script>
<style type="text/css">
    .Textwrap {  
        width: 150px; 
        white-space: nowrap; 
        text-overflow: ellipsis; 
        overflow: hidden; 
    } 
</style>
<script>
       jQuery(document).ready(function() {
          
       });
   </script>
<script type="text/javascript">
  function urlredirect() {
      
      var sUserAgent = navigator.userAgent.toLowerCase(); 
      if ((sUserAgent.match(/(ipod|iphone os|midp|ucweb|android|windows ce|windows mobile)/i))) {
          var thisUrl = window.location.href;
          window.location.href = thisUrl.substr(0,thisUrl.lastIndexOf('/')+1)+'mobpage/'; //跳转为网址后面加mobile的路径
      }
  }
  urlredirect();
  </script>
</body>
</html>